package com.nulldev.util.web.nTube.pages.misc;

import com.nulldev.util.languages.json.uniapi.UniJsonValue;
import com.nulldev.util.web.HttpServer3.Response;
import com.nulldev.util.web.HttpServer3.pages.v3.HttpPage3;
import com.nulldev.util.web.nTube.util.INTubeInstance;

public class APIInstanceInfoPage extends HttpPage3 {

	private final INTubeInstance nts;

	public APIInstanceInfoPage(final INTubeInstance nts) {
		super("/api/instanceInfo");
		this.nts = nts;
	}

	@SuppressWarnings("resource")
	@Override
	public Response onRequest(final Request request) {
		if (!this.nts.hasInstanceInfo())
			return this.fail(404);
		final UniJsonValue v = this.nts.getInstanceInfo().asObject();
		return new Response(200, v, v).setCustomMime("application/json");
	}

}
